import { ref, computed } from "vue";
import { defineStore, acceptHMRUpdate, createPinia } from "pinia";
import piniaPluginPersistedstate from "pinia-plugin-persistedstate";
export const pinia = createPinia();
pinia.use(piniaPluginPersistedstate);
export const useStore = defineStore("store", {
    // 推荐使用 完整类型推断的箭头函数
    state: () => {
        return {
            processState: "1",
        };
    },
    actions: {
        setState(num: any) {
            this.processState = num;
            console.log("参数改变");
        },
    },
    getters: {
        getState: (state) => state.processState,
    },
    persist: {
        // 修改存储中使用的键名称，默认为当前 Store的 id
        key: "store",
        // 修改为 sessionStorage，默认为 localStorage
        storage: window.sessionStorage,
        // 部分持久化状态的点符号路径数组，[]意味着没有状态被持久化(默认为undefined，持久化整个状态)
        paths: ["processState"],
    },
});
if (import.meta.hot) {
    import.meta.hot.accept(acceptHMRUpdate(useStore, import.meta.hot));
}
